ScriptJam
HTML JS CSS Result Run Stop save Save
  * If forking, Nick name must be different than the one used in original post. Using the same Nick as original will just update/overwrite the post.

Your Nick Name Allowed chars: a-z, 0-9 . @ - Choose a Nick you will remember. Use the same nick each time you post to allow yourself and others to find your posts.

Pass Key Allowed chars: A-Z, a-z, 0-9, @ . ! % $ # ?-. Choose a Pass Key you will remember (write it down). This allows you to post again later using the same nick from above.

Title

Description

 
Save
Cancel

Formatting and posting tips:

* [URL]https://yoururl.com[/URL] - shows as https://yoururl.com

* Double line spacing creates gaps between lines.

* Use the same Nick / Pass Key each time you post helps people find all your posts. (helpful if your post contains a link to your site)

* Do your best work. The more popular / active your post is the likely with get featured on the site.

* Inactive or poor quality posts are subject to deletion.

Things to note:

* Pass keys are non-recoverable which means if you forget/lose it you will have to create a new Nick .

* The system is designed to let you be as anonymous as you want. However if you post links or other data that can expose your identity then you accept any/all risks and agree not to hold ScriptJam liable in any way.

* Do not submit copyrighted material.

* Do not blatantly copy another post without forking.

* We reserve the right to remove posts for any reason we deem necessary.

bretby: bret  on February 18, 2020, 5:30 am     link    heart
All functions in JavaScript are closures. They will retain their state while there is still a reference to them. In this example notice how 'msg' variable retains the state at which it is initialized. This was made for use as part of work related training session where teach those new to JS.
HTML
JS
CSS
 
X
If this is your Jam enter edit mode.

Explore other Jams

♥ My favorites Copy the paste (to top of JS) then edit this function to load libs from a CDN.
SCRIPTJAM('https://code.jquery.com/jquery-3.4.1.min.js');
Embed / share JAM using this code: (Note: change ?s=result to one of html | js | css | result to embed with that pane open by default. Change the style attribute to your liking.
<div style='height: 400px; overflow: hidden; resize: vertical;'><iframe style='height: 100%; width: 100%; overflow-y: auto;' src='https://scriptjam.com/script/b6vzcor/closure-example/?s=result&split=true&frame=true' ></iframe></div>
Scratch pad: Add notes here (not saved).
+ add