[Javascript] Objects and Functions

What makes objects different is that we can create more of them. Every time we use the {} object literal, we create a brand new object value:

let shrek = {};
let donkey = {};

 

Functions:

for (let i = 0; i < 7; i++) {
  let dig = function() {
    // Do nothing
  };
  console.log(dig);
}
The snippet above contains one function definition in the code, but it creates seven function values! This is why separating these concepts is important.
Every time we execute a line of code that contains a function declaration, a brand new function value appears in our universe.
posted @ 2020-02-25 18:46  Zhentiw  阅读(103)  评论(0)    收藏  举报