pattern « Var « Javascript Data Type Q&A

Home
Javascript Data Type Q&A
1.Array
2.Clojure
3.date
4.decimal
5.function
6.global
7.loop
8.math
9.number
10.object
11.Regular Expression
12.scope
13.String
14.Var
15.variable
Javascript Data Type Q&A » Var » pattern 

1. Why does this regexp work as var pattern = / ... / but not as a var pattern = RegExp("...")?    stackoverflow.com

<script type="text/javascript">
var str="Jestem bardzo, bardzo zadowolony. Mo?na powiedzie?, ?e jestem równie? uszcz??liwiony i uspokojony."; 

patt1=new RegExp( "\bi\b", "g"); //<--- (to find the single word: "i")

document.write(str.match(patt1));
</script>
It works well as var pattern = ...

2. Is var self = this; a bad pattern?    stackoverflow.com

I find myself needing:

var self = this;
a lot within my javascript 'classes'. Although this is commonly done, it feels a bit wrong. What I'm hoping to find in this question is a ...

3. Javascript single var pattern. Am I overloading it?    stackoverflow.com

I've read in Stoyan Stefanov book about single var pattern. Also it's good by JSLint. But I've noticed in my code that I maybe overload this pattern. It occurs that whole my ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.