From d8b43c12e8d45fa9475a7eba3f9b5b1ad20653dd Mon Sep 17 00:00:00 2001 From: Gui Lin Date: Wed, 6 Mar 2013 12:15:11 +0800 Subject: [PATCH] improve for loop --- snippets/javascript.snippets | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/javascript.snippets b/snippets/javascript.snippets index de50a0c..edbb878 100644 --- a/snippets/javascript.snippets +++ b/snippets/javascript.snippets @@ -52,13 +52,13 @@ snippet case ${3} # for (...) {...} snippet for - for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3: += 1}) { - ${4:$1[$2]} + for (var ${2:i} = 0, l = ${1:arr}.length; $2 < l; $2 ++) { + var ${3:v} = $1[$2];${4:} } # for (...) {...} (Improved Native For-Loop) snippet forr - for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3: -= 1}) { - ${4:$1[$2]} + for (var ${2:i} = ${1:arr}.length - 1; $2 >= 0; $2 --) { + var ${3:v} = $1[$2];${4:} } # while (...) {...} snippet wh