Wednesday 9 February 2022

Nodejs - ECMA Concept

ECMA Concept

-> 'let ' is an scope varible it can't be use as globle varible

-> if we'r using 'var' in place of let it will re-assign last defined value (means

    var a = 30

    var a = 30

    console.log("value of a is:"+a)

OUTPUT-

        value of a is = 30

)

if we are using 'let' inplace of var then it look like

let a=40;

let a=30;

OUTPUT

SyntaxError: Identifier 'a' has already been declared

    at wrapSafe (internal/modules/cjs/loader.js:1001:16)

    at Module._compile (internal/modules/cjs/loader.js:1049:27)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

    at Module.load (internal/modules/cjs/loader.js:950:32)

    at Function.Module._load (internal/modules/cjs/loader.js:790:12)

    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)

    at internal/main/run_main_module.js:17:47 


if we using scope varible

let a=30;


function esma_example(){
    let a = 40;
    console.log("value of a under function :"+a);
}

esma_example()
console.log("value of a:"+a);


output-

value of a under function :40

value of a:30


No comments:

Post a Comment

Kotlin - Observer

 Rxjava -  Observer - Based on data view willl render (react) karega. trotling -> making stream for execution (Means clicks event fire kr...