basic keywords or variables in nodejs |node js tutorials

 

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


in impoer names.john, names.peter
if we  export any variable - it can cal it as global variable


require(modules locatioion)


single export
module.exports = sayHi

instant export

module.exports.items = ['item1','item2'];

const person = {
name :'bpb',
}

module.exports.singlePerson = person;


without export

output

input
7-mind-grenade.js



node js documentation - https://nodejs.org/dist/latest-v14.x/docs/api/http.html

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



https://www.w3schools.com/nodejs/ref_modules.asp


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

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...