随笔分类 - Javascript
摘要:The ability to natively format dates and times using the browser is impressive. You may find yourself not needed to grab libraries such as moment.js o
阅读全文
摘要:JavaScript numbers and CSS hexadecimal numbers don't play very well together. You can solve this with a conversion function that takes the number, con
阅读全文
摘要:State + Event + Interpreter: const machine = { initial: "idle", states: { idle: { on: { FETCH: "pending", }, }, pending: { on: { RESOLVE: "resolved",
阅读全文
摘要:import './assets/css/style.css'; const app = document.getElementById('app'); app.innerHTML = ` <div class="todos"> <div class="todos-header"> <h3 clas
阅读全文
摘要:Let's see the following code first: let button = document.getElementById("button"); button.addEventListener("click", (e) => { console.log(e) }); We ha
阅读全文
摘要:Macro: refer to webapis, setTimeout, setInterval Micro: refer to Promise based api Execution order Sync Task > Micro Task > Macro Task Example: const
阅读全文
摘要:Big or non decimal numbers are sometimes hard to read inside code. Numeric separators are now part of the javascript specification and allow us to mak
阅读全文
摘要:When implementing the store partten, we need to be careful about mutation. class DataStore { private lessons: Lesson[] = []; private lessonsSubject =
阅读全文
摘要:const app = document.getElementById('app'); app.innerHTML = ` <h1>JavaScript DOM</h1> <ul id="list"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul>
阅读全文
摘要:const app = document.getElementById('app'); app.innerHTML = ` <h1>JavaScript DOM</h1> <div class="item"></div> `; const item = document.querySelector(
阅读全文
摘要:In this lesson we will learn about how to define real private properties in javascript classes. Before: class Pasta { constructor(name) { this._name =
阅读全文
[Javascript] Create an Async Generator and Loop Through Generated Promises with "For Await Of" Loops
摘要:Generators can yield promises which can work with the "for await of" loop syntax. This lesson shows how all the pieces fit together and explains why t
阅读全文
摘要:The "for await of" loop syntax enables you to loop through an Array of Promises and await each of the responses asynchronously. This lesson walks you
阅读全文
摘要:NaN == NaN // false NaN NaN // false Object.is(NaN, NaN) // true Number.isNaN(NaN) // true typeof NaN // number Because NaN is number type, so there i
阅读全文
摘要:Learn how to use custom events to expose internal events from withing a web component. class MyWelcome extends HTMLElement { constructor() { super();
阅读全文
摘要:What makes objects different is that we can create more of them. Every time we use the {} object literal, we create a brand new object value: let shre
阅读全文
摘要:Let's see a simple code example: let pet = "dog" console.log(pet) We have console.log(pet) inside the code, when you read it, you might say: Pass ´pet
阅读全文
摘要:It can be confusing to understand when and how the .prototype and .proto properties are created and used. They both seem to imply having something to
阅读全文