Ce n’est pas un défi mais une question, j’ai pensé que c’était sur le sujet à cause de
Les questions non liées à la résolution de problèmes de programmation ou à un type de défi particulier sont également abordées.
Passons maintenant à la question:
Est-il possible d'écrire du code JavaScript avec seulement 5 lettres? JSFuck le fait déjà avec 6 symboles, !+[]()
mais je me demande si le !
personnage est nécessaire.
JSFuck fonctionne avec une combinaison de transtypage en chaîne (en ajoutant un tableau vide), de transtypage en nombre (en écrivant un + devant) et de transtypage en boolean en négation. Par exemple:
[] \\ Empty array
+[] \\ Cast to number -> 0
!+[] \\ Negate -> true
!+[]+[] \\ Cast to string -> "true"
De cette chaîne, nous pouvons extraire toutes ses lettres en utilisant les crochets avec un nombre à l'intérieur, et tout nombre peut être créé en ajoutant true ensemble autant de fois.
Comme cela, beaucoup de lettres peuvent être trouvées et peuvent être concaténées en chaînes. La chaîne la plus importante à pouvoir créer est "constructor"
parce qu’elle peut être utilisée pour obtenir la Function
fonction de n’importe quelle fonction, et que cet objet peut être utilisé pour exécuter des chaînes en JavaScript:
[]["find"] \\ the function Array.prototype.find
[]["find"]["constructor"] \\ the Function object
[]["find"]["constructor"](string)() \\ same as eval(string)
Comme vous pouvez le voir, !
a 2 utilisations ici:
- Création de nombres pour sélectionner des lettres parmi des chaînes.
- Casting au booléen pour obtenir
"true"
et"false"
.
Le premier de ces 2 peut également être fait en utilisant l' ++
incrémenteur, pas directement sur 0
, mais il peut être utilisé sur des éléments à l'intérieur d'un tableau:
+[] \\ 0
[+[]] \\ [0]
[+[]][+[]] \\ [0][0] -> 0
++[+[]][+[]] \\ ++[0][0]-> 1
++[[]][+[]] \\ also works because ++ casts to number
Donc, tous les nombres peuvent être créés sans !
.
Le second est plus difficile. L'importance de "true"
et "false"
réside dans les lettres "r"
et "s"
, qui apparaissent tous les deux dans "constructor"
. Je l' ai déjà trouvé toutes les autres lettres "constructor"
au moyen de "undefined"
, "Infinity"
, "NaN"
et en lançant des fonctions à des chaînes.
Donc, la question ultime: (comment) pouvez-vous créer des booléens, ou les lettres "r"
et "s"
en JavaScript en utilisant seulement +[]()
?
La lettre "l"
pourrait aussi aider. Il peut être obtenu sous forme null
mais je n’ai pas pu obtenir cette valeur avec ces 5 symboles. Il peut par exemple être utilisé pour obtenir des booléens si on a déjà "s"
:
[]["includes"]() \\ false
[+[]]["includes"](+[]) \\ true
La lettre "l"
et "k"
ensemble donneraient accès à "r"
:
([]+[])["link"]() \\ "<a href="undefined"></a>"
N'importe quel moyen d'obtenir un booléen null
ou n'importe quelle lettre r s l k
serait très utile!
Une bibliothèque de ce que nous avons:
Array.prototype.find: [] [(([] []] + []) [(++ [[]] [+]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) (([] []] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) ( ++ [[]] [+ []])]) (([] [[]] + []) [++ [[]] [+]]) (([] [[]]) + []) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] Infini: + ((++ [[]] [+ []] + []) + (([] []] + []) [(++ [[]] [+ []]) + (+ + [[]] [+ []]) + (++ [[]] [+ []])]) + (++ [[]] [+]] + [+] + (+ []) + (+ [])) NaN: + [] [[]] indéfini: [][[]] 0: + [] 1: ++ [[]] [+ []] 2: (++ [[]] [+ []]) + (++ [[]] [+ []]) 3: (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+ []]) 4: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[] ] [+ []]) 5: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) (+ [++] ] [+ []]) + (++ [[]] [+ []]) 6: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) (+ [++] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 7: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+ []]) 8: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) (+ [++] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) + (++ [[]] [+ []]) 9: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) (+ [++] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) a: (+ [] [[]] + []) [++ [[]] [+ []]] c: ([] [(([] [[]] + []) [(++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []]) + (++ [[]] [+ []])]) (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ [ []] [+ []])] + (([] [[]] + []) [++ [[]] [+]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] d: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []])] e: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [ + []])] f: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [ + []]) + (++ [[]] [+ []])] i: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [ + []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] n: ([] [[]] + []) [++ [[]] [+ []]] o: ([] [(([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+]]) (+ [[]] [+ []]) + (++ [[]] [+ []])]) (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ [ []] [+ []])] + (([] [[]] + []) [++ [[]] [+]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] t: (+ ((++ [[]] [+]] + []) + (([] []] + []) [(++ [[]] [+]]) ( ++ [[]] [+ []]) + (++ [[]] [+ []])]) (++ [[]] [+]] + [+] ) + (+ []) + (+ [])) + []) [(++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+ [] ]]] u: ([] [[]] + []) [+ []] v: ([] [(([] [[]] + []) [(++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []]) + (++ [[]] [+ []])]) (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ [ []] [+ []])] + (([] [[]] + []) [++ [[]] [+]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + [] + ((++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []]))] y: (+ ((++ [[]] [+]] + []) + (([] [[]] + []) [(++ [[]] [+]]) + ( ++ [[]] [+ []]) + (++ [[]] [+ []])]) (++ [[]] [+]] + [+] ) + (+ []) + (+ [])) + []) [(++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+ [] ]) + (++ [[]] [+ []])] I: (+ ((++ [[]] [+]] + []) + (([] [[]] + []) [(++ [[]] [+]]) ( ++ [[]] [+ []]) + (++ [[]] [+ []])]) (++ [[]] [+]] + [+] ) + (+ []) + (+ [])) + []) [+ []] N: (+ [] [[]] + []) [+ []] "": ([] [(([] []] + []) [(++ [[]] [+]]) + (++ [[]] [+]]) (+ + [[]] [+ []]) + (++ [[]] [+ []])]) (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []])) + (([] [[]] + []) [++ [[]] [+]]) + (([] [[]] + [ ]) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [+ (++ [[]] [+ [] ] + [] + ((++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ + [[]] [+ []]) + (++ [[]] [+ []]))) (: ([[[] [[]] + []) [(++ [[]] [+]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ [ []] [+ []])] + (([] [[]] + []) [++ [[]] [+]]) + (([] [[]] + [] ) [[++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [+ (++ [[]] [+ []] + [] + ((++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]))] ): ([] [(([] [[]] + []) [(++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []]) + (++ [[]] [+ []])]) (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ [ []] [+ []])] + (([] [[]] + []) [++ [[]] [+]]) + (([] [[]] + [] ) [[++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [+ (++ [[]] [+ []] + [] + ((++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []])))] {: ([] [(([] [[]] + []) [(++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []]) + (++ [[]] [+ []])]) (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ [ []] [+ []])] + (([] [[]] + []) [++ [[]] [+]]) + (([] [[]] + [] ) [[++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [+ (++ [[]] [+ []] + [] + ((++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]))] }: ([] [(([] [[]] + []) [(++ [[]] [+]]) + (++ [[]] [+]]) (+ [[]] [+ []]) + (++ [[]] [+ []])]) (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) (+ [ []] [+ []])] + (([] [[]] + []) [++ [[]] [+]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [+ ((++ [[]] [+ [] ]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + [] + ((++ [[]] [+]]) + ( ++ [[]] [+ []])))] .: (+ (++ [[]] [+]] + [] + (++ [[]] [+]]) + ([] [[]] + []) [(++ [ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+ [] ] + [] + (+ []) + (+ []))) + []) [++ [[]] [+ []]] ,:[[]] [([] [(([] []] + []) [(++ [[]] [+]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) (([] []] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) ( ++ [[]] [+ []])]) (([] [[]] + []) [++ [[]] [+]]) (([] [[]]) + []) [(++ [[]] [+ []]) + (++ [[]] [+]])]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + ([] [(([] []] + []) [ (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [ + []])] + (([] [[]] + []) [(++ [[]] [+]]) + (++ [[]] [+]]) ( ++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]])) + (([] [[] ] + []) [++ [[]] [+ []]]) + (([] [[]] + []) [(++ [[]] [+]]) + (++ [[]] [+ []])]] + []) [(++ [[]] [+]]) + (++ [[]] [+]]) (+ [ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]] )] + ([] [[]] + []) [++ [[]] [+ []]] + ([] [(([] []] + [] ]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+ []]) ]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+]]) (+ [++] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]])) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + []) [(++ [[]] [+]]) + (++ [[]] [ + []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) + (+ [] [[]] + []) [++ [[]] [+ []]] + (+ ((++ [[]] [+]] + []) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+]]) + (++ [[]] [+]]) + ( ++ [[]] [+ []] + []) + (+ []) + (+ []) + (+ [])) + []) [(++ [[]] [+ [] ]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+]]) (+ ]] [+ []]) + (++ [[]] [+ []])]] ([[]]) + []
eval
2453 caractères avec window
permis.