Ex1 Find out a type
let a=10
console.log("Value of a : " + a)
console.log("Type of a : " + typeof a)
let b="hello"
console.log("Value of b : " + b)
console.log("Type of b : " + typeof b)
Ex2 Object
let dept = {
name:"CSE",
description : " Computer Science and Engineering",
code : 44,
address: { block : "CS" , location : "TN"}
};
console.log(dept);
console.log(typeof dept);
console.log(dept.address.location);
Ex3 Function
function add(n1,n2)
{
return n1+n2;
}
let a=10
let b=20
console.log(a, '+' , b , '=' , add(a,b))
Ex4 String
let x ="hello"
let y="world"
console.log(x+y);
Ex no 5 Http and local host port
let http = require("http");
http.createServer(function (req ,res)
{
res.writeHead(200,{'Content-Type':'text/plain'});
res.end("My First Web Program");
}).listen(9090, ()=>console.log("My web Server is running on 9090"));
Ex 6 Upper Case
let http = require('http');
let uc = require('upper-case');
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write(uc.upperCase("Welcome u all to this workshop"));
res.end();
}).listen(9000, () => {
console.log("Server listening on http://localhost:9000/");
});
Ex7 Event
let e=require('events');
let eh=new e.EventEmitter();
let myhandler= function() {
console.log("test");
}
eh.on('demo', myhandler);
eh.emit('demo');
eh.emit('demo');
eh.emit('demo');
eh.emit('demo');
Ex 8 Timer
function myfun(){
console.log("my training");
}
setTimeout(myfun,3500);
No comments:
Post a Comment