Firefox扩展 - 最佳实践 [英] Firefox Extensions - best practices

查看:134
本文介绍了Firefox扩展 - 最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个Firefox扩展,但最近读了一些文章,解释了通过简单地将应用程序名称附加到变量的前面来避免变量名称冲突的做法是不正确的。



不幸的是我一直在这样做。最好的做法是什么?我认为这是以某种方式命名空间的变量。我发现了各种关于在主对象中包装everythign的文章,但可悲的是没有这样的例子。

任何人都可以指向我一个很好的教程,甚至是一个简单的扩展,使用最佳做法?



谢谢!

解决方案

Peter Michaux 非常好地解释了Javascript的命名空间

I've been writing a Firefox extension, but have recently read a few articles explaining that it's bad practice to avoid variable name clashes by simple appending the application name to the front of the variable.

Unfortunately I have been doing this. What is the best practice instead? I assume it's to somehow namespace the variables. I've found various articles about wrapping everythign in a master object, but sadly no examples of this.

Can anyone point me to a good tutorial, or even a simple extension, that uses best-practices?

Thanks!

解决方案

Peter Michaux explains Javascript namespacing very nicely.

这篇关于Firefox扩展 - 最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆