globals
_dirname
_filename
require
module
process
any where u can access that varaivble is called global variables
in app.js
setInterval()
setinterval(()=>{},1000)
setinterval(()=>{
console.log('helloworld')},1000)
call back funciton is conole.log
to understand the code is easy - divide whole program into parts
write a function in es6
const sayHi =()=> {}
const sayHi = (name) => {
console.log('hello ${name}');
}
sayHi('susam');
const john ='hon';
sayHi(john)
fucntion sayHi(name)
{
console.log'hellow name');
}
every file in node is module
modules -encapsulated code ( only share minimum)
it will print that page
console.log(module);
local varoables and global varaiables
glaobl to uise in another module they are using export that required varaible
multiple exports
if we export any variable - it can cal it as global variable
module.exports = sayHi
instant export
module.exports.items = ['item1','item2'];
const person = {
name :'bpb',
}
module.exports.singlePerson = person;
without export
input
7-mind-grenade.js
i ssen in one lecture -
varaible declaration
used in fucntion
run this page
after taht
varaible declaration in page
functin in one page
import in one page
run that page
use built in modules
info about current user
current os type release totalmem
const path = require('path')
path module;
path.sep -> console .log
path.join('/content','subfolder','test.txt');
path.basename
No comments:
Post a Comment