Expressions with slashes are highlighted incorrect

2019-07-02 21:15发布

First off: I'm not talking about multi line commenting, I don't think. The problem is occurring when there is a space between the / and the * such as

draw.arc(x, y, radius, Math.PI/2, Math.PI/2, true);

In dreamweaver, the text

/2,Math.PI/

Goes green.

I've googled but to no avail. I'm sure it's something dumb but I'm stumped.

Also note: still occurs when the Math.PI formula is defined as a variable

3条回答
不美不萌又怎样
2楼-- · 2019-07-02 21:32

Dreamweaver is interpreting that as a regex for syntax highlighting.

The regex notation /regex/ is the most notoriously difficult part to parse in all of Javascript.

Your code is fine. You could try adding spaces around the /. I've often seen that work.

查看更多
在下西门庆
3楼-- · 2019-07-02 21:39

It is something dumb: Dreamweaver has a bug in it. Your code must still execute. That is a perfectly valid sequence of characters, that does not result in a comment.

查看更多
在下西门庆
4楼-- · 2019-07-02 21:42

As stated below, it's a parsing issue with Dreamweaver - interpreting your syntax as a regular expression.

A solution to this problem would be to create a variable for that value. Additionally, it's more efficient than doing the same operation more than once.

var piOver2 = Math.PI / 2;

draw.arc(x, y, radius, piOver2, piOver2, true);
查看更多
登录 后发表回答