相关疑难解决方法(0)

如何检查字符串数组是否包含JavaScript中的一个字符串?

我有一个字符串数组和一个字符串.我想针对数组值测试此字符串并应用条件结果 - 如果数组包含字符串do"A",否则执行"B".

我怎样才能做到这一点?

javascript arrays string testing

221
推荐指数
5
解决办法
42万
查看次数

什么是JavaScript >>>运算符以及如何使用它?

我正在查看Mozilla的代码,它为Array添加了一个过滤方法,它有一行代码让我很困惑.

var len = this.length >>> 0;
Run Code Online (Sandbox Code Playgroud)

我以前从未见过用于JavaScript的>>>.
它是什么,它做了什么?

javascript operators bit-shift

141
推荐指数
6
解决办法
3万
查看次数

javascript - 将正则表达式与项数组匹配

在JavaScript中是否有一种方法可以获得字符串与正则表达式数组匹配的布尔值?

例子是('if'语句代表我想要实现的目标):

var thisExpressions = [ '/something/', '/something_else/', '/and_something_else/'];
var thisString = 'else';

if (matchInArray(thisString, thisExpressions)) {

} 
Run Code Online (Sandbox Code Playgroud)

javascript arrays expression

41
推荐指数
3
解决办法
8万
查看次数

在包含保留字时设置CSS代码

我想做的事情:正如标题中所述,我想设置一个单词的CSS,如果它是一个保留字.


HTML

<html>
    <body>
        <code id="java">
            public static void main(String[] args)<br>
            {
                <pre>    System.out.println("Hello World!");</pre>
            }
        </code>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)


jQuery的

$(document).ready(function()
{
    // Get the text inside the code tags
    var code  = $("#java").text();

    // Split up each word
    var split = code.split(' ');

    // Array of reserved words
    var array = ["abstract","assert","boolean","break","byte","case",
                 "catch","char","class","const","continue","default",
                 "do","double","else","else if","enum","extends","final",
                 "finally","float","for","goto","if","import","implements",
                 "instanceof","int","interface","long","native","new","null",
                 "package","private","protected","public","return","short",
                 "static","strictfp","super","switch","synchronized","this",
                 "throw","throws","transient","void","volatile","while"];

    // Added when text contains a reserved word
    var css = {'font-weight':'bold','color':'#2400D9'}

    array = jQuery.map(array, function(n,i)
    {
        for …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery reserved-words

7
推荐指数
1
解决办法
1209
查看次数