测试字符串是否可以通过正确的变量名称的最可靠方法是什么?我脑子里有几个解决方案,但我不太确定该使用哪一个:
// using <iframe> helper
// assuming I have hidden <iframe> inserted in document.body{}:
var _hidden_iframe_id = "iframe"+ Date.now();
var _fr = document.createElement("iframe");
_fr.setAttribute("id", _hidden_iframe_id);
_fr.setAttribute("name", _hidden_iframe_id);
_fr.style.display = "none";
document.body.appendChild(_fr);
// and .eval()-ing a string as a variable in <iframe>'s .contentWindow{}:
String.prototype.isidentifier = (function (owns, _frames, rnd, ifr_name) {
// use private cache to save evaluated results
var cache = {};
// main
return function () {
// guard against code alike strings
// takes everything up to left …Run Code Online (Sandbox Code Playgroud) 当我在注释块内输入新行时,有人能指出我如何使SublimeText插入注释延续双斜线?
// I have comments like this, and when I enter a '\n'
// it break's out of comment-entering mode
like this (drops slashes, cursor stays at leftmost column)
// and I want to have them automatically inserted after hiting '\n'
// like this
Run Code Online (Sandbox Code Playgroud)
我可能在调整偏好文件时意外改变了,我不知道如何设置它.
这是我的用户首选项:
{
"animation_enabled": false,
"auto_complete_commit_on_tab": true,
"auto_complete_delay": 200,
"auto_complete_size_limit": 2097152,
"auto_complete_triggers":
[
{
"characters": "<",
"selector": "text.html"
},
{
"characters": ".",
"selector": "source.python"
},
{
"characters": ".",
"selector": "source.javascript"
}
],
"bold_folder_labels": true, …Run Code Online (Sandbox Code Playgroud) 我需要一个具有某种可能性的函数,它会触发,例如:
function broken_fn ( function () { console.log( Math.random() ); }, 33 ) {
// code...
}
Run Code Online (Sandbox Code Playgroud)
用于简单的在线游戏我正在努力...