31.6k views
4 votes
In JavaScript, which of the statements below can be used for string declaration?

1) var cst="PHPKB Knowledge Base Software";
2) var cst=new String("PHPKB Knowledge Base Software");
a) Either (1) or (2)
b) Only (1)
c) Neither (1) nor (2)
d) Only (2)

User Broguyman
by
8.2k points

1 Answer

2 votes
For a string primitive, b. For a String object, d. If we're non-specific, a.
User Oshyshko
by
9.7k points