Difference between a class and an object in Javascript

后端 未结 3 1086
被撕碎了的回忆
被撕碎了的回忆 2021-01-04 01:42

What\'s the difference between

var myView = function () {
//something goes here
};

and

var myView = function () {
//somet         


        
3条回答
  •  青春惊慌失措
    2021-01-04 02:33

    var myView = function () { //something goes here };

    This is function expression without being executed. And var myView = function () { //something goes here return { a: x, b: y }(); This function expression gets executed due to parenthesis "()" place after function resulting in return of Object.

    Again New keyword use for creating constructor and can not be applicable for Object.

提交回复
热议问题