This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const cat = { | |
| color: 'white', | |
| printColor() { setTimeout(function(){ | |
| console.log('this', this); | |
| }, 1000) | |
| } | |
| } | |
| cat.printColor() // Window |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const cat = { | |
| color: 'white', | |
| printColor() { | |
| console.log(this.color) | |
| } | |
| } | |
| console.log(cat.printColor()) //white | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const printName = function (firstName, lastName) { | |
| console.log(arguments[0]) //John | |
| console.log(arguments[1]) //Doe | |
| } | |
| printName('John','Doe') | |
| const printName = (name) => `Meu nome é ${name}` | |
| console.log(arguments[0]) // arguments is not defined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const sumNumbers = (n1, n2) => | |
| { | |
| return n1 + n2 | |
| } | |
| console.log(sumNumbers(2,2)) //console.log 4 | |
| //Com apenas uma linha no return podemos diminuir ainda mais | |
| const sumNumbers = (n1, n2) => { return n1 + n2 } | |
| console.log(sumNumbers(2,2)) //console.log 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const printName = function (firstName, lastName) { | |
| console.log(`${firstName} ${lastName}`) | |
| } | |
| printName('John','Doe') //console.log "John Doe" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function printName(firstName, lastName) { | |
| console.log(`${firstName} ${lastName}`) | |
| } | |
| printName('John','Doe') //console.log "John Doe" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express') | |
| const app = express() | |
| const produtosRoutes = require('./routes/produtos') | |
| const usuariosRoutes = require('./routes/usuarios') | |
| app.use(produtosRoutes); | |
| app.use(usuariosRoutes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require('path') | |
| const express = require('express') | |
| const router = express.Router() | |
| router.get('/usuarios', (req, res, next) => { | |
| res.sendFile(path.join(__dirname, '../', 'views', 'usuarios', 'usuarios.html')) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express') | |
| const router = express.Router() | |
| const path = require('path') | |
| router.get('/', (req, res, next) => { | |
| res.sendFile(path.join(__dirname, '../', 'views', 'produtos', 'produtos.html')) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express') | |
| const app = express() | |
| const produtosRoutes = require('./routes/produtos') | |
| app.use(produtosRoutes); | |
| app.listen(3000, () => { | |
| console.log('Example app listening on port 3000!') |
NewerOlder