小编Mat*_*att的帖子

为什么javascript在if语句中接受逗号?

我偶然发现了一些javascript语法似乎应该产生某种类型的解析错误但不会:

if (true, true) {console.log('splendid')} else {console.log('horrid')} // splendid
if (true, false) {console.log('splendid')} else {console.log('horrid')} // horrid
Run Code Online (Sandbox Code Playgroud)

虽然所有表达式都被执行,但似乎只有最后一个表达式会影响逻辑:

if  (console.log('super'), true) {console.log('splendid')} // super splendid
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么这是有效的JavaScript语法?它有什么实际用途吗?

javascript logic parsing

62
推荐指数
4
解决办法
2万
查看次数

使用Firebug将JQuery加载到任何页面中

有没有人有一个片段可以将jquery加载到firebug的任何页面上?我经常遇到我更喜欢使用熟悉的jq语法检查的网站.

例如,假设我想从页面中提取价格列表 - 最好是启动firebug,从谷歌CDN安装jquery,然后输入$('li.prices').每个(...).

jquery firebug

15
推荐指数
2
解决办法
8665
查看次数

有没有办法将html冲到Sinatra的电线上

I have a Sinatra app with a long running process (a web scraper). I'd like the app flush the results of the crawler's progress as the crawler is running instead of at the end.

I've considered forking the request and doing something fancy with ajax but this is a really basic one-pager app that really just needs to output a log to a browser as it's happening. Any suggestions?

ruby sinatra

6
推荐指数
1
解决办法
1598
查看次数

更改Sublime 2中的注释字符以获取特定语法

//当我点击cmd- /时,Sublime的Haml语法用于注释.我想改写它的使用-#.我怎么做?

sublimetext2

2
推荐指数
1
解决办法
1448
查看次数

标签 统计

firebug ×1

javascript ×1

jquery ×1

logic ×1

parsing ×1

ruby ×1

sinatra ×1

sublimetext2 ×1