Skip to content

Instantly share code, notes, and snippets.

View vipulbhj's full-sized avatar
🏠
Working from home

Vipul vipulbhj

🏠
Working from home
View GitHub Profile
let arr1 = [1, 2, 4, 5];
let arr2 = arr1;
arr1.length = 0;
console.log(arr2); // Output :- []
let arr1 = [1, 2, 4, 5];
let arr2 = arr1;
arr1 = [];
console.log(arr2);
// -> Output [1, 2, 4, 5];
let arr1 = [1, 2, 4, 5];
let arr2 = array1;
arr1 = [];
console.log(arr2);
// -> Output [1, 2, 4, 5];
let arr = [
{
firstName: 'Jon',
lastName: 'Doe'
},
{
firstName: 'example',
lastName: 'example'
},
{
@vipulbhj
vipulbhj / symbol.js
Created March 23, 2019 19:01
For the Symbols blog
const sym1 = Symbol();
const sym2 = Symbol();
sym1 === sym2;
// false
const sym3 = Symbol.for("cat");
const sym4 = Symbol.for("cat");
sym3 === sym4;
@vipulbhj
vipulbhj / index.js
Last active November 23, 2018 19:46
Routing Module.
const http = require('http');
const fs = require('fs');
// All the routes are defined here.
const router = [
{
'url': '/',
'fn': (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
@vipulbhj
vipulbhj / index.js
Created November 23, 2018 18:49
Basic Node JS server using http module.
const http = require('http');
const PORT = process.env.PORT || 5000;
const app = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write("Hello World");
res.end();
});