Is script tag inside javascript string object currently forbidden? - javascript-objects

I try this: let textValue='<script></script>'
but I get an error stated
Uncaught SyntaxError: Invalid or unexpected token
unexpected token
Unterminated string literal
I am wondering do javascript currently forbid the use of <script> tag for string object.

You can do it like this:
let textValue='<script>content<\/script>';
console.log(textValue);

Related

My react app gives an error for some reason

Error:
src\images\navbar.js
Line 2:11: Parsing error: Unexpected token, expected "from" (2:11)
src\navbar.js
Line 2:11: Parsing error: Unexpected token, expected "from" (2:11)
the project on GitHub: https://github.com/PufflyMan/airbnb-exp-clone
It's pretty straightforward code but no matter what I tried, I couldn't fix it. Thanks for attention!
It just fixed itself. I didn't do anything

angular 1 json pipe causing Lexer Error: Unterminated quote

I'm displaying data in json format using angular1's json pipe:
<pre>{{myJSONData | json}}</pre>
myJSONData contains single quotes. For example:
{"info": "Info about Men's and Womens Shoes"}
I get this parsing error:
angular.js:14199 Error: [$parse:lexerr] Lexer Error: Unterminated quote at columns 732-749 ["Info about ] in expression...
Looks like the single quotes cause the error.
But, I cannot manually escape the single quotes because I don't know what the data looks like.
I simply get the data from an api call and display it.

json objects from registry.nodejs.org shows error

how can i use jsonP to get all the NPM packages that contain a keyword.
I used
https://registry.npmjs.org/-/_view/byKeyword?startkey=["Keyword"]&&endkey=["keyword",{}]&group_level=3
and it throws an error that : is unexpected in console.
The correct search query is:
https://registry.npmjs.org/-/_view/byKeyword?startkey=[%22keyword%22]&endkey=[%22keyword%22,{}]&group_level=3
You need to use "keyword" instead of "Keyword" and '&' instead of '&&'

ng-init parse syntax error

I run this
res.render('NamesPieChart',{ChartLabels : JSON.stringify(["January","February","March","April","May","June"]), DataList : JSON.stringify(datalist), title : "test"});
I can get the datalist with no issues. However, the ChartLabels I get the error:
Syntax Error: Token ',' is an unexpected token at column 47 of the expression [m_datalist=[3,6,2,1,1,2];m_chartlabels=January,February,March,April,May,June] starting at [,February,March,April,May,June].
It is like it doesn't see it as a string.
Any suggestions?
The code that works for me to import ng-init is:
ng-init= "m_datalist=<%-DataList%>;m_chartlabels=<%=ChartLabels%>">

Parse error while rendering the pdf file in angularjs app

When I try to access the pdf file which is public using the angular-pdf-viewer I got the following error message on console.
Error: [$parse:syntax] Syntax Error: Token ':' is an unexpected token at column 5 of the expression [http://pucdocket.s3.amazonaws.com/VA/PUE-2010-00039/122913.pdf] starting at [://pucdocket.s3.amazonaws.com/VA/PUE-2010-00039/122913.pdf].
here is my pdf directive for rendering the pdf file:
<pdf-viewer delegate-handle="my-pdf-container" url="http://pucdocket.s3.amazonaws.com/VA/PUE-2010-00039/122913.pdf" scale="1" show-toolbar="true" ></pdf-viewer>
could anyone help on this issue?
all the samples seems to be suggesting define url on scope and reference it. But you may try the following, which stringifys the url
<pdf-viewer delegate-handle="my-pdf-container" url="'http://pucdocket.s3.amazonaws.com/VA/PUE-2010-00039/122913.pdf'" scale="1" show-toolbar="true" ></pdf-viewer>

Resources