/    Sign up×
Community /Pin to ProfileBookmark

understanding the usage of forward slash in element creation.

guys have a look at the below peice of code ::

[CODE]
var $dots = “<div class=”anim-dots”></div>”;

console.log($dots) // “<div class=”anim-dots”></div>”
[/CODE]

if i do ::

[CODE]
var $dots = “<div class=”anim-dots”></div>”;

console.log($dots)

// i get an error as follows ::

/*
Exception: SyntaxError: missing ; before statement
*/[/CODE]

what is the / doing in the code really ?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Kevin2Jul 05.2015 — Read the section about "Special Characters" on this page:

http://www.w3schools.com/js/js_strings.asp

For what it's worth you can achieve the same output by nesting the quotes:
var $dots = '&lt;div class="anim-dots"&gt;&lt;/div&gt;';

console.log($dots)
Copy linkTweet thisAlerts:
@gautamz07authorJul 05.2015 — thanks .
×

Success!

Help @gautamz07 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...