Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita3d690a

Browse files
authored
New notes about scoping variables.
1 parent60beecf commita3d690a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,17 @@ me().on("click", async event => {
367367
*`e`,`ev`,`evt` = event
368368
*`f`,`fn` = function
369369
370-
#### Scope functions inside`<script>`
371-
* ⭐ On`me()`
370+
#### Scope functions and variables inside`<script>`
371+
* ⭐ Use a block
372+
*`{let scoped=1;functionhey(text) {alert(text) };me().on('click',ev=> {hey("hi") }) }`
373+
*`let` is scoped in`{ }` blocks!
374+
* ⭐ Use`me()`
372375
*`me().hey= (text)=> {alert(text) }`
373376
*`me().on('click', (ev)=> {me(ev).hey("hi") })`
374-
* ⭐ Usea block:`{functionhey(text) {alert(text) };me().on('click',ev=> {hey("hi") }) }`
375-
* ⭐ Use an event:`me().on('click',ev=> {/* add and call function here*/ })`
377+
* ⭐ Usean event
378+
*`me().on('click',ev=> {/* add and call function here*/ })`
376379
* Use an inline module:`<script type="module">`
377-
*Note:`me()`will no longer see`parentElement` so explicit selectors are required:`me(".mybutton")`
380+
*Warning: When using a module`me()`can no longer see`parentElement`, this means explicit selectors are required:`me(".mybutton")`
378381
379382
#### Select a void element like`<input type="text"/>`
380383
* Use:`me('-')` or`me('prev')` or`me('previous')`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp