Curso Javascript Completo 2018

Aula 251 - Construtores, o operador new e objetos passados por referĂȘncia

var hoje = new Date(); console.log(hoje); console.log(typeof hoje); console.log(hoje.getDay()); /*****************************/ var x = 0; function mudaX(x) { var y = x; console.log('mudaX: ', y); } mudaX(10); console.log('x: ', x); /******************************/ var x1 = [0]; function mudaX1(x1) { // debugger; var y1 = x1; y1.push(2); x1.push(3); console.log('mudaX1: '); console.log(x1); console.log(y1); } mudaX1(x1); console.log('x1: '); console.log(x1); /******************************/ var x2 = [0]; function mudaArr(x2) { // debugger; var y2 = x2; y2.push(2); x2.push(3); console.log('mudaX2: '); console.log(x2); console.log(y2); } mudaArr(x2); console.log('-----------'); var n = 0; function mudaN(n) { var n2 = n; console.log(++n2); } mudaN(n); console.log(n);