On Wednesday, 13 April 2011 19:37:59 UTC-3, Asen Bozhilov wrote:
>
> J.R.:
>
> > Instead of:
> > if (window.ActiveXObject) {
> >
> > We should use:
> > if (typeof window.ActiveXObject !== "undefined") {
>
> I would not use both approaches. I would use:
>
> if (typeof ActiveXObject != 'undefined
On Thu, Apr 14, 2011 at 12:36 AM, Jason Persampieri
wrote:
> One other thing to keep in mind... when you define functions(methods) within
> your constructor function, every new object will have their own copy of that
> function definition. When the methods are defined on the prototype, that
> cod
I have found this presentation very helpful in understanding the
difference between keydown/keypress/keyup:
http://www.yuiblog.com/blog/2009/04/27/video-ppk-jsevents/
On Thu, Apr 14, 2011 at 11:08 AM, Tim Down wrote:
> Yes. Use the keydown event instead. Use keypress for detecting text
> input an
There's a catch. The keydown doesn't fire repetitively when you're
holding
arrow keys. In a way that makes sense because you're not explicitly
pushing
the key down (same for up). And since keypress doesn't fire (the
character
rule is so silly..) you have no choice but to simulate this your
On Thursday, 14 April 2011 10:32:53 UTC-3, J.R. wrote:
>
> I always ask myself when do I really need the Java-like approach in
> Javascript, such as using a constructor function and the 'new' operator, and
> I don't find a reasonable answer to go about writing code in that way.
>
> In your case,
On Saturday, 9 April 2011 02:46:58 UTC-3, planon wrote:
>
> I was reading Ben Cherry's blog post on Writing Testable Javascript
> and I came across this example:
>
> function Templater() {
> this._templates = {};
> }
>
> Template.prototype = {
> _supplant: function(str, params) {
>
IMHO, the only reason to define member functions from within the
constructor is to make them what DC calls "privileged" functions: thanks
to the closure, they have access to private state (local variables of
the constructor function) yet are publicly accessible.
Any public function that just r
On 14 April 2011 10:38, Peter van der Zee wrote:
> On Thu, Apr 14, 2011 at 11:25 AM, Diego Perini
> wrote:
>>
>> On Thu, Apr 14, 2011 at 10:37 AM, Amit Agarwal wrote:
>> > 'keypress' event works well in Chrome except for arrow keys.
>> >
>> > Any solution?
>>
>> Use keydown/keyup to catch contr
On Thu, Apr 14, 2011 at 11:25 AM, Diego Perini wrote:
> On Thu, Apr 14, 2011 at 10:37 AM, Amit Agarwal wrote:
> > 'keypress' event works well in Chrome except for arrow keys.
> >
> > Any solution?
>
> Use keydown/keyup to catch control (unprintable) keystrokes as suggested
> by Tim.
>
There's a
On Thu, Apr 14, 2011 at 10:37 AM, Amit Agarwal wrote:
> 'keypress' event works well in Chrome except for arrow keys.
>
> Any solution?
>
>
> -Amit
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/jsmentors@jsmentors.com/
>
> To search vi
On 14 April 2011 09:37, Amit Agarwal wrote:
> 'keypress' event works well in Chrome except for arrow keys.
>
> Any solution?
Yes. Use the keydown event instead. Use keypress for detecting text
input and keydown/keyup for detecting general keystrokes. The
following page is a very useful reference
'keypress' event works well in Chrome except for *arrow keys*.
Any solution?
-Amit
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/jsmentors@jsmentors.com/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/jsmen
On Thu, Apr 14, 2011 at 10:01 AM, Poetro wrote:
> It just behaves totally differently from the embedded
2011/4/14 Rob Steward :
> Hi all, short time lurker and first time poster.
>
> I just started writing a new tools library, and one of the methods is
> some syntactic sugar that allows you to manipulate the DOM and include
> a javascript file in the head element.
>
> [code]
> function include(files)
On Thu, Apr 14, 2011 at 12:36 AM, Matthias Reuter wrote:
>
> You are trying to call the method 'get_v1' of f1. This has not been
> declared either, so a TypeError is thrown. You might say, hey, I defined
> that function in its prototype, so it should be taken from there.
> Unfortunately, 'prototyp
On Mon, Apr 11, 2011 at 5:53 AM, wrote:
> Hello,
>
> I start to learn JS.
>
>
Welcome, Sam!
> **
> var f1 = function () {
> this.v1 = 5;
> }
>
Here you define a simple function. The only weird thing is the "this"
references inside. Now, "this.v1" doesn't mean, "give
One other thing to keep in mind... when you define functions(methods) within
your constructor function, every new object will have their own copy of that
function definition. When the methods are defined on the prototype, that
code is shared amongst all of the created objects.
_jason
On Thu, Apr
**
var f1 = function () {
this.v1 = 5;
}
f1.prototype.get_v1 = function () { return this.v1; };
var f2 = new f1();
f1.v1 // return nothing
f1.get_v1() // nothing
f2.v1 // return 5
f2.get_v1() // return 5
**
Why f1.v1 and f1.get_v1 return no
Because the f1 is the function. And expression 'this.v1 = 5' is in it's body.
So you must execute function at least.
Also, 'this' is passed to the function by callee.
If you just call the function, you will not pass 'this' value, so it
will refer to the global object.
If you use the 'new' keyword,
> Also, 'this' is passed to the function by callee.
Oops, typo: I mean caller of course =)
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/jsmentors@jsmentors.com/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/
It's just another way to create object by some template (or prototype).
Using "your" method: var o = Templater();
Using prototype: var o = new Template(); // see the 'new' keyword
Usage of created object is the same: o._supplant(...);
But also there's few differences in creating derived objects.
21 matches
Mail list logo