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
{"version":1,"resource":"file:///c%3A/dev/learn-penguin/pages/level/%5Bworld%5D/%5Bid%5D.page.tsx","entries":[{"id":"9tdt.tsx","timestamp":1653504720885},{"id":"jDGs.tsx","timestamp":1653504732111},{"id":"MBQa.tsx","timestamp":1653504747566},{"id":"GQjv.tsx","timestamp":1653504823082},{"id":"Lw3z.tsx","source":"undoRedo.source","timestamp":1653504827867},{"id":"r3mT.tsx","timestamp":1653504833056},{"id":"j0mh.tsx","source":"undoRedo.source","timestamp":1653504838631},{"id":"FV1x.tsx","timestamp":1653504845182},{"id":"NSBn.tsx","timestamp":1653504958300},{"id":"eXJ4.tsx","timestamp":1653504987900},{"id":"cQZy.tsx","source":"Workspace Edit","timestamp":1653516573565},{"id":"XC0w.tsx","timestamp":1653516595199},{"id":"5sZe.tsx","source":"Workspace Edit","timestamp":1653516620077},{"id":"Ndpg.tsx","timestamp":1653516622869},{"id":"QXsn.tsx","timestamp":1653516925743},{"id":"8BEe.tsx","timestamp":1653516937811},{"id":"w2EA.tsx","timestamp":1653516961799},{"id":"vkkV.tsx","timestamp":1653517188004},{"id":"gvlE.tsx" |
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
// Using && will prevent nonsense code from being executed. | |
false && console.log(NoNsEnSe_CoDE) // nothing happens | |
// You'll frequently see && used for type-checking. | |
const bananas = "🍌🍌🍌🍌🍌" | |
typeof bananas === "string" && console.log(bananas) // 🍌🍌🍌🍌🍌 | |
// For example, you might be expecting an array, not a string. | |
Array.isArray(bananas) && bananas.push("🍌") // nothing happens |
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
// The typeof null is "object" in JavaScript. | |
console.log(typeof null === "object") // true | |
// Let's look at type checking a Date object. | |
const date = new Date() | |
console.log(typeof date) // "object" | |
console.log(Object.prototype.toString.call(date)) // [object Date] | |
console.log(date.constructor) // function Date() | |
console.log(date.constructor.name) // "Date" | |
console.log(date instanceof Date) // true |
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
// && can be used to prevent errors, because the error won't be thrown. | |
const nullBanana = null | |
try { | |
console.log(nullBanana.length) | |
} catch (e) { | |
console.log(e) | |
} | |
// Output: "TypeError: null has no properties." | |
// Using && short-circuits the code, so the TypeError doesn't occur. |
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 object = { "🔑key🔑": "💸value💸" } | |
console.log(typeof object) // "object" | |
console.log(object !== null) // true | |
console.log(object != null) // true | |
console.log(typeof null) // "object" | |
console.log(null !== null) // false | |
console.log(null != null) // false | |
console.log(typeof undefined) // "undefined" |