Skip to content

"Deleting Variables": Snowman (v1.3)#


Through using the Underscore template library available in Snowman, JavaScript can be used within passages without a <script> tag. The delete operator can be used in JavaScript to remove a variable.



Twee Code#

:: StoryTitle
Snowman: Deleting Variables

:: UserScript[script]
window.story = {};

window.story.example = "an example!";

:: Start
What is the value of the property "example" of the object window.story? <%= window.story.example %>

[[Delete the value!]]

:: Delete the value!

// Delete the variable
delete window.story.example;


[[Test for value]]

:: Test for value
Does "example" still exist as part of the object window.story? <%= window.story.hasOwnProperty("example") %>

Twee Download