This file contains 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
import React, { useState, useEffect } from "react"; | |
export default function App() { | |
const [text, setText] = useState(""); | |
const [data, setData] = useState([ | |
{ | |
id: 1, | |
name: "abacate" | |
}, | |
{ |
This file contains 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
// criando dois objetos | |
let carro1 = {modelo: "fiat", cor: "azul"} | |
let carro2 = carro1 | |
// aLterando a propriedade "cor" do carro1 | |
carro1.cor = "verde" | |
// exibinDo As propriedades do carro2 | |
console.log("carro2: " + carro2) |
This file contains 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
// criando uma várivel com valor do tipo primitivo | |
let idade1 = 10 | |
let idade2 = idade1 | |
idade1 = 15 | |
console.log(idade2) |
This file contains 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
//--------------utilizando spread operator-------------// | |
// criando dois objetos | |
let carro1 = {modelo: "fiat", cor: "azul"} | |
let carro2 = {...carro1} | |
// aLterando a propriedade "cor" do carro1 | |
carro1.cor = "verde" | |
// exibinDo As propriedades do carro2 | |
console.log(carro2) |
This file contains 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
//---------------------utilizando object.asign---------------------// | |
// criando dois objetos | |
let carro1 = {modelo: "fiat", cor: "azul"} | |
let carro2 = Object.assign({}, carro1) | |
// aLterando a propriedade "cor" do carro1 | |
carro1.cor = "verde" | |
// exibinDo As propriedades do carro2 | |
console.log(carro2) |
This file contains 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
//--------------------arrays-------------------// | |
let amigos = ["coraline", "andrade", "kotlin", "batman"] | |
let friends = amigos.slice() | |
amigos.push("zé ninguém") | |
console.log(friends) |
This file contains 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
// boolean (true / false) | |
let isOpen: boolean | |
isOpen = true | |
// string ('foo', "foo", `foo`) | |
let message: string | |
message = `foo ${isOpen}` | |
// number | |
let total: number |
This file contains 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
/** Type Inference */ | |
let title = 'title' | |
title = 1 // dont work | |
title = 'lol' // work |
This file contains 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
/** Type Allias e Union */ | |
function logDetails(uid: number | string, item: string) { | |
console.log(`A product with ${uid} has a title as ${item}`) | |
} | |
// uid: number | string => union | |
logDetails(123, 'sapato') | |
logDetails('123', 'sapato') |
This file contains 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 _validateCPF( | |
value: string, | |
handleResponse: (value: Record<string, unknown>) => void | |
): void { | |
let data = {}; | |
let sum; | |
let rest; | |
sum = 0; | |
if (value === '000.000.000-00') { |
OlderNewer